import '../../state.dart';
import '../app_colors.dart';
import 'package:flutter/material.dart';

import '../chart_sample.dart';

class ChartHolder extends StatelessWidget {
  final ChartSample chartSample;

  const ChartHolder({
    Key? key,
    required this.chartSample,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: [
        Row(
          children: [
            const SizedBox(width: 6),
            Text(
              chartSample.name,
              style: const TextStyle(
                color: AppColors.primary,
                fontSize: 18,
                fontWeight: FontWeight.bold,
              ),
            ),
            Expanded(child: Container()),
            // IconButton(
            //   onPressed: () => ChartUtils().tryToLaunchUrl(chartSample.url),
            //   icon: const Icon(
            //     Icons.code,
            //     color: AppColors.primary,
            //   ),
            //   tooltip: 'Source code',
            // ),
          ],
        ),
        const SizedBox(height: 2),
        Container(
          decoration: const BoxDecoration(
            color: AppColors.itemsBackground,
            borderRadius: BorderRadius.all(Radius.circular(8)),
          ),
          child: chartSample.builder(context),
        ),
      ],
    );
  }
}
